﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SMTC.WebCommon.Common;
using SMTC.BO.UserPower;

public partial class UserPower_PublishNews :BasePage
{
   private  InsertNews _publishnews = new InsertNews();
   private CheckReceiver _checkreceiver = new CheckReceiver();
    protected void Page_Load(object sender, EventArgs e)
   {
       FCKeditor_News.ToolbarSet = "Default";
    }

    protected void ButtonPublishNews_Click(object sender, EventArgs e)
    {
        int flag = 0;
        string[] arry = TextBoxReceiver.Text.Split(';');
        string username = this.UserName; //Session["UserName"].ToString();
        string time = System.DateTime.Now.ToString();
        for (int i = 0; i < arry.Length; i++)
        {

            string receiver = _checkreceiver.Check_Receiver(arry[i].ToString());
            if (arry[i].ToString() != receiver)
            {
                flag += 1;
                ClientScript.RegisterStartupScript(Page.GetType(), "", "checkfalse()", true);
                
            }
        }
        if (flag == 0)
        {
            //_publishnews.Insert_News(this.UserName, time, DropdownImportant.SelectedIndex, TextBoxtTitle.Text.ToString().Trim(), FCKeditor_News.Value,TextBoxReceiver.Text .ToString ().Trim ());
            //ClientScript.RegisterStartupScript(Page.GetType(), "", "publishok()", true);
            for (int j = 0; j < arry.Length; j++)
            {

                _publishnews.Insert_News(this.UserName, time, DropdownImportant.SelectedIndex, TextBoxtTitle.Text.ToString().Trim(), FCKeditor_News.Value, arry[j]);

            }
            ClientScript.RegisterStartupScript(Page.GetType(), "", "publishok()", true);
        }
    }
}